package strategy.pay;

import java.util.HashMap;

public class PaymentStrategy {

    private PaymentStrategy(){

    }

    public static HashMap<String,Payment> map=new HashMap<>();
    static {
        map.put(PayWay.Ali_Pay.getValue(),new AliPay());
        map.put(PayWay.JindDong_Pay.getValue(),new JingDongPay());
        map.put(PayWay.WeChat_Pay.getValue(),new WeChatPay());
        map.put(PayWay.Default_Pay.getValue(),new AliPay());
    }

    public static Payment getPayment(String key) {
        if (!map.containsKey(key)){
           return map.get(PayWay.Default_Pay.getValue());
        }
        Payment payment = map.get(key);
        return payment;
    }
}
